<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags" %>
<%@taglib prefix="display" uri="http://displaytag.sf.net" %>
<%@taglib prefix="sx" uri="/struts-dojo-tags" %>
<% 
	String contextPath = request.getContextPath(); 
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title></title>
<link href="style/store.css" rel="stylesheet" type="text/css">
<link href="style/displaytagex.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<%=contextPath%>/include/js/validatorNumericAndBackslash.js"></script>
<script type="text/javascript">
	function disableDate(){
		if(document.getElementById("getToday").checked){
			document.getElementById("startDate").disabled=true;
			document.getElementById("endDate").disabled=true;
		}else{
			document.getElementById("startDate").disabled=false;
			document.getElementById("endDate").disabled=false;
		}
	}
	
	function generatePdf(){
		window.open("generateAuditPdfAction.action");
	}
</script>
</head>
<body>
<s:form name="formName" method="post" >
	<s:if test="#request.dispMode == 1 ">
		<table border="1" align="center">
			<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
				<td colspan="4" align="center">Audit Logs</td>
			</tr>
			<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
				<td><label>From: </label></td>
				<td align="left" ><sx:datetimepicker name="startDate" id="startDate" displayFormat="MM/dd/yyyy" 
					type="date" onkeypress="return checkKeyPressed(event,'startDate');" /></td>
				<td><label>To: </label></td>
				<td align="left" ><sx:datetimepicker name="endDate" id="endDate" displayFormat="MM/dd/yyyy" 
					type="date" onkeypress="return checkKeyPressed(event,'endDate');" /></td>
			</tr>
			<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
				<td colspan="2" ><label>Today: </label></td>
				<td colspan="2"><s:checkbox name="getToday" id="getToday" onclick="disableDate();" /></td> 
			</tr>
			<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
				<td colspan="2">Logged User:</td>
				<td colspan="2"><s:select name="loggedUser" 
							headerKey="all"
							headerValue="-All-"
			                list="#session.userList" 
			                listKey="username" 
			                listValue="username"
			               />
				</td>
			</tr>
			<tr style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
				<td colspan="4" align="center"><s:submit action="searchAuditLogsAction" value="Search Logs" cssClass="button" /></td>
			</tr>
		</table>
	</s:if>
	<s:if test="#request.dispMode == 1">
		<center>
		<display:table name="auditlogList" uid="row" pagesize="10" class="dataTable"
			requestURI="goToAuditLogAction.action">
			<display:column title="ID" >
				<s:url id="viewlogdetails" action="viewLogDetailsAction">
						<s:param name="al_id" value="#attr.row.al_id"></s:param>
				</s:url>
				<s:a href="%{viewlogdetails}"><s:property value="#attr.row.al_id"/></s:a>
			</display:column>
			<display:column property="al_log_date" title="Date"></display:column>
			<display:column property="al_log_time" title="Time"></display:column>
			<display:column property="al_user" title="User"></display:column>
			<display:column property="al_grand_total" title="Sub Total"></display:column>
		<display:setProperty name="paging.banner.placement" value="top" />
		</display:table>
		</center>
		<table align="right" border="1" align="center" width="50%" >
		<s:if test="#session.grandTotal != 0">
		<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
			<td width="61%" align="right" style="padding-right: 10px" ><label>Grand Total:</label></td>
			<td><s:property value="#session.grandTotal" /> </td>
		</tr>
		<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
			<td colspan="2" width="61%" align="right" style="padding-right: 10px" ><input type="button" onclick="generatePdf();" value="Pdf Report" class="button" /> </td>
		</tr>
		</s:if>
		</table>
	</s:if>
	<s:if test="#request.dispMode == 2">
		<table border="1" align="center" width="50%">
			<tr>
				<td colspan="2" class="verdana" height="30" align="center" bgcolor="#336699"><font color="#ffffff">Audit Log</font></td>
			</tr>
			<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
				<td><label>Log ID: </label></td>
				<td><s:property value="auditLog.al_id" /> </td>
			</tr>
			<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
				<td><label>Log Date: </label></td>
				<td><s:property value="auditLog.al_log_date" /> </td>
			</tr>
			<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
				<td><label>Log Time: </label></td>
				<td><s:property value="auditLog.al_log_time" /> </td>
			</tr>
			<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
				<td><label>User: </label></td>
				<td><s:property value="auditLog.al_user" /> </td>
			</tr>
			<tr>
				<td colspan="2" class="verdana" height="30" align="center" bgcolor="#336699"><font color="#ffffff">Purchased Products</font></td>
			</tr>
			<tr>
				<td colspan="2" align="center" width="100%">
					<display:table name="productList" uid="row" pagesize="10" class="dataTable"
						requestURI="viewLogDetailsAction.action">
						<display:column property="name" title="Product Name"></display:column>
						<display:column property="quantity" title="Quantity"></display:column>
						<display:column property="subTotal" title="Sub Total"></display:column>
					</display:table>
				</td>
			</tr>
			<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
				<td width="70%" align="right" style="padding-right: 10px" ><label>Grand Total:</label></td>
				<td><s:property value="auditLog.al_grand_total" /> </td>
			</tr>
			<tr style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
				<td colspan="2" align="center"><s:submit action="goToAuditLogAction" value="Back" cssClass="button" /></td>
			</tr>
		</table>
	</s:if>
</s:form>
</body>
</html>